package com.briup.jz.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import com.briup.jz.bean.OrderComment;
import com.briup.jz.bean.OrderCommentExample;
import com.briup.jz.dao.OrderCommentMapper;
import com.briup.jz.service.IOrderCommentService;
import com.briup.jz.utils.CustomerException;

@Service
public class OrderCommentServiceImpl implements IOrderCommentService {

@Autowired	
private OrderCommentMapper ordercommentMapper;

@Override
public void saveOrUpdate(OrderComment ordercomment) throws CustomerException {
	if(ordercomment.getId()!=null) {
		ordercommentMapper.updateByPrimaryKey(ordercomment);
	} else {
		
		ordercommentMapper.insert(ordercomment);
	}
}
@Override
public List<OrderComment> query(Long id,String content,String status) {
	OrderCommentExample example = new OrderCommentExample();
	if(id!=null){
		example.createCriteria().andIdEqualTo(id);
	}
	if(content!=null){
		example.createCriteria().andContentEqualTo(content);
	}
	if(status!=null){
		example.createCriteria().andStatusEqualTo(status);
	}
	List<OrderComment> list = ordercommentMapper.selectByExample(example);
	return list;
}

@Override
public void deleteById(long id) throws CustomerException {
	OrderComment ordercomment =ordercommentMapper.selectByPrimaryKey(id);
	if (ordercomment == null) {
		throw new CustomerException("要删除的分类信息不存在");
	}
	ordercommentMapper.deleteByPrimaryKey(id); 
}
	

	

}
